package com.yxhl.zoume.domain.interactor.passenger;

import com.yxhl.zoume.data.http.repository.passenger.PassengerRepository;
import com.yxhl.zoume.data.http.rest.param.base.RequestParamImpl;
import com.yxhl.zoume.data.http.rest.param.passenger.GetPassengersParam;
import com.yxhl.zoume.data.http.rest.response.passenger.GetPassengersResponse;
import com.yxhl.zoume.domain.DomainConstants;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by Xboy on 16/3/17.
 */
public class GetPassengersUseCase extends com.yxhl.zoume.domain.interactor.base.UseCase<GetPassengersResponse> {

    private final PassengerRepository repository;

    @Inject
    public GetPassengersUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                                @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                                PassengerRepository repository) {
        super(uiThread, executorThread);
        this.repository = repository;
    }

    @Override
    protected Observable<GetPassengersResponse> buildObservable(RequestParamImpl param) {
        return repository.getAddedPassengers((GetPassengersParam) param)
                .subscribeOn(executorThread)
                .observeOn(uiThread);
    }
}
